package com.zzpct.wh.work.shucheng.ui.home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;

import com.zzpct.wh.work.shucheng.Adapter.BookAdapter;
import com.zzpct.wh.work.shucheng.Bean.Book;
import com.zzpct.wh.work.shucheng.R;

import org.litepal.LitePal;

import java.util.ArrayList;
import java.util.List;

public class HomeFragment extends Fragment {
    private ListView booklv;
    BookAdapter adapter;
    List<Book> bookList=new ArrayList<>();
    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_home, container, false);
        initView(root);
        return root;
    }

    private void initView(View root) {
        booklv=root.findViewById(R.id.booklv);
        bookList= LitePal.findAll(Book.class);
        adapter=new BookAdapter(getContext(),R.layout.book_item,bookList);
        booklv.setAdapter(adapter);
    }
}